/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JEditMemoDialog.java
 *
 * Created on 2009-11-16, 11:48:36
 */

package cn.ekuma.epos.qkorder.dialog;

import com.openbravo.pos.base.AppLocal;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.SwingUtilities;

/**
 *
 * @author Administrator
 */
public class JEditMemoDialog extends javax.swing.JDialog {
    private boolean isOk;
    private String retStr;
    /** Creates new form JEditMemoDialog */
    public JEditMemoDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
    }

    private JEditMemoDialog(Dialog dialog, boolean b) {
        super(dialog,b);
    }

    public static JEditMemoDialog getDialog(Component parent,String text){
        Window window = SwingUtilities.getWindowAncestor(parent);
        JEditMemoDialog myMsg;
        if (window instanceof Frame) {
            myMsg = new JEditMemoDialog((Frame) window, true);
        } else {
            myMsg = new JEditMemoDialog((Dialog) window, true);
        }
        myMsg.init(text);
        myMsg.applyComponentOrientation(parent.getComponentOrientation());
        return myMsg;
    }



    private void init(String text){
         initComponents();
         jEditorPane1.setText(text);
         jEditorPane2.setText(text);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel7 = new javax.swing.JPanel();
        m_jButtonOK = new javax.swing.JButton();
        m_jButtonCancel = new javax.swing.JButton();
        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jEditorPane1 = new javax.swing.JEditorPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jEditorPane2 = new javax.swing.JEditorPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/button_ok.png"))); // NOI18N
        m_jButtonOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N
        m_jButtonOK.setFocusPainted(false);
        m_jButtonOK.setFocusable(false);
        m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
        m_jButtonOK.setRequestFocusEnabled(false);
        m_jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_jButtonOKActionPerformed(evt);
            }
        });

        m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/button_cancel.png"))); // NOI18N
        m_jButtonCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N
        m_jButtonCancel.setFocusPainted(false);
        m_jButtonCancel.setFocusable(false);
        m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
        m_jButtonCancel.setRequestFocusEnabled(false);
        m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_jButtonCancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(193, Short.MAX_VALUE)
                .addComponent(m_jButtonOK)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(m_jButtonCancel)
                .addGap(25, 25, 25))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(m_jButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(m_jButtonCancel, 0, 0, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel7, java.awt.BorderLayout.PAGE_END);

        jSplitPane1.setDividerLocation(100);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setMinimumSize(new java.awt.Dimension(400, 300));
        jSplitPane1.setPreferredSize(new java.awt.Dimension(400, 300));

        jEditorPane1.setEditable(false);
        jEditorPane1.setFocusable(false);
        jEditorPane1.setRequestFocusEnabled(false);
        jScrollPane1.setViewportView(jEditorPane1);

        jSplitPane1.setTopComponent(jScrollPane1);

        jEditorPane2.setMinimumSize(new java.awt.Dimension(200, 100));
        jEditorPane2.setPreferredSize(new java.awt.Dimension(200, 100));
        jScrollPane2.setViewportView(jEditorPane2);

        jSplitPane1.setRightComponent(jScrollPane2);

        getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-408)/2, (screenSize.height-366)/2, 408, 366);
    }// </editor-fold>//GEN-END:initComponents

    private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed
        this.retStr= jEditorPane2.getText();
        isOk=true;
        dispose();
}//GEN-LAST:event_m_jButtonOKActionPerformed

    private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed
        dispose();
}//GEN-LAST:event_m_jButtonCancelActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JEditorPane jEditorPane1;
    private javax.swing.JEditorPane jEditorPane2;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JButton m_jButtonCancel;
    private javax.swing.JButton m_jButtonOK;
    // End of variables declaration//GEN-END:variables

    public boolean isOk() {
        return isOk;
    }

    public String getRetStr() {
        return retStr;
    }

}
